//
//  HomeTableViewCell.m
//  SimpleNote
//
//  Created by mac on 2017/11/21.
//  Copyright © 2017年 上海LOL信息技术服务有限公司. All rights reserved.
//

#import "HomeTableViewCell.h"

@implementation HomeTableViewCell

-(instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
    if (self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]) {
        [self setupUI];
    }
    return self;
}

-(void)setupUI{
    
    // http://blog.csdn.net/si1279571489/article/details/53381705
    
    UIView *backview = [[UIView alloc]init];
    [self addSubview:backview];
    
    [backview addSubview:self.titleLabel];
    [self.titleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.top.equalTo(backview).offset(12*ScaleX);
        make.right.equalTo(backview).offset(-12*ScaleX);
        make.height.mas_equalTo(20*ScaleX);
    }];
    
    [backview addSubview:self.contentLabel];
    self.contentLabel.numberOfLines = 2;
    [self.contentLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.right.equalTo(self.titleLabel);
        make.top.equalTo(self.titleLabel.mas_bottom).mas_offset(5);
    }];
    
    [backview addSubview:self.timeLabel];
    [self.timeLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.right.equalTo(self.titleLabel);
        make.top.equalTo(self.contentLabel.mas_bottom).mas_offset(5);
        make.height.mas_equalTo(20*ScaleX);
    }];
    
    [backview mas_makeConstraints:^(MASConstraintMaker *make) {
        make.edges.equalTo(self);
        make.bottom.equalTo(self.timeLabel).offset(5);
    }];

}

#pragma mark --- get
-(UILabel *)titleLabel{
    if (_titleLabel == nil) {
        _titleLabel = [[UILabel alloc]init];
        _titleLabel.font = [UIFont boldSystemFontOfSize:22*ScaleX];
        _titleLabel.textAlignment = NSTextAlignmentLeft;
    }
    return _titleLabel;
}

-(UILabel *)contentLabel{
    if (_contentLabel == nil) {
        _contentLabel = [[UILabel alloc]init];
        _contentLabel.font = [UIFont systemFontOfSize:18*ScaleX];
        _contentLabel.textAlignment = NSTextAlignmentLeft;
    }
    return _contentLabel;
}

-(UILabel *)timeLabel{
    if (_timeLabel == nil) {
        _timeLabel = [[UILabel alloc]init];
        _timeLabel.font = [UIFont systemFontOfSize:15*ScaleX];
        _timeLabel.textAlignment = NSTextAlignmentLeft;
        _timeLabel.textColor = [UIColor lightGrayColor];
    }
    return _timeLabel;
}


@end
